package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_collectionService;
import com.balakitbbs.entity.Bala_collection;
   /**
    * bala_collection Controller类
    */ 
@Controller
public class Bala_collectionController{
	@Autowired
	private Bala_collectionService bala_collectionservice;

//增加收藏表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_collection")
public String addBala_collection(Bala_collection bala_collection,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_collection.setCdate(new Date());
	bala_collection.setId(UUID.randomUUID().toString());
	bala_collectionservice.addBala_collection(bala_collection);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_collection.do";
}


//删除收藏表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_collection")
public String delBala_collection(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_collectionservice.delBala_collection(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_collection.do";
}


//修改收藏表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_collection")
public String updateBala_collection(Bala_collection bala_collection,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_collection.setUdate(new Date());
	bala_collectionservice.updateBala_collection(bala_collection);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_collection.do";
}


//查询收藏表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_collection")
public ModelAndView selectBala_collections(Bala_collection bala_collection,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_collectionCount = bala_collectionservice.selectBala_collectionsByPOJOCount(bala_collection);
	Page page = new Page(pageIndex, pageSize, selectBala_collectionCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_collectionservice.selectBala_collectionsByPojoPage(spu, bala_collection));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_collection());
	modelAndView.setViewName("/WEB-INF/page/bala_collection.jsp");
	return modelAndView;
}

}

